// 引入 mongoose
const mongoose = require('mongoose')

// 创建模式对象
const Schema = mongoose.Schema
// 创建写入约束规则
let userRules = new Schema({
  email: {
    type: String,
    unique: true,
    required: true
  },
  username: {
    type: String,
    required: true,
    unique: true
  },
  password: {
    type: String,
    required: true
  },
  mobile: {
    type: Number,
    unique: true
  },
  date: {
    type: Date,
    default: new Date().getTime()
  },
  enable_flag: {
    type: String,
    default: "Y"
  }
})

// 暴露 user 这个写入规则
module.exports = mongoose.model('user', userRules)
